package com.example.spring.controller;
import com.example.spring.common.Result;
import com.example.spring.entity.Obj;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HelloController {
    // @RequestMapping(value = "/", method = RequestMethod.GET)
    @GetMapping("/hello")
    public Result hello(String data){
        int a = 0;
        int b = 10/a;
        return Result.success(data);
    }

    // @RequestMapping(value = "/post", method = RequestMethod.POST)
    @PostMapping("/post")
    public Result post(@RequestBody Obj obj){
        return Result.success(obj);
    }

    // @RequestMapping(value = "/put", method = RequestMethod.PUT)
    @PutMapping("/put")
    public Result put(@RequestBody Obj obj){
        return Result.success(obj);
    }

    // @RequestMapping(value = "/delete", method = RequestMethod.Delete)
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id){
        return Result.success(id);
    }

    /**
     * 批量删除
     */
    @DeleteMapping("/delete")
    public Result deleteBatch(@RequestBody List<Integer> ids){
        return Result.success(ids);
    }
}
